package com.sun.jdk.funref;

import java.util.function.Consumer;

public class FunctionRefTest01 {

    static int[] a= {10,20,30,40,50,60};
    
    public static void main(String[] args) {
        getSum((var) -> {
            int sum = 0;
            for (int i: var){
                sum += i;
            }
            System.out.println(sum);
        });
    }
    
    // 求一个数组的和
    private void getTotal(int[] arr){
        int sum = 0;
        for(int i : arr){
            sum += i;
        }
        System.out.println(sum);
    }
    
    public static void getSum(Consumer<int[]> consumer){
        consumer.accept(a);
    }
}
